package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Evaluate;
import com.ruoyi.wechat.service.IEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营地评价Controller
 * 
 * @author ruoyi
 * @date 2024-07-30
 */
@RestController
@RequestMapping("/camp/evaluate")
public class EvaluateController extends BaseController
{
    @Autowired
    private IEvaluateService evaluateService;

    /**
     * 查询营地评价列表
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(Evaluate evaluate)
    {
        startPage();
        List<Evaluate> list = evaluateService.selectEvaluateList(evaluate);
        return getDataTable(list);
    }

    /**
     * 导出营地评价列表
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:export')")
    @Log(title = "营地评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Evaluate evaluate)
    {
        List<Evaluate> list = evaluateService.selectEvaluateList(evaluate);
        ExcelUtil<Evaluate> util = new ExcelUtil<Evaluate>(Evaluate.class);
        util.exportExcel(response, list, "营地评价数据");
    }

    /**
     * 获取营地评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") String evaluateId)
    {
        return success(evaluateService.selectEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增营地评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:add')")
    @Log(title = "营地评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Evaluate evaluate)
    {
        return toAjax(evaluateService.insertEvaluate(evaluate));
    }

    /**
     * 修改营地评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:edit')")
    @Log(title = "营地评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Evaluate evaluate)
    {
        return toAjax(evaluateService.updateEvaluate(evaluate));
    }

    /**
     * 删除营地评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:remove')")
    @Log(title = "营地评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable String[] evaluateIds)
    {
        return toAjax(evaluateService.deleteEvaluateByEvaluateIds(evaluateIds));
    }
}
